package com.xylx.interview.loadbalance;

import java.util.Arrays;
import java.util.List;

/**
 * 完全轮询算法
 */
public class PollServer {
    public static List<String> list = Arrays.asList("10.180.11.126:8888", "10.180.11.128:8888", "10.180.11.130:8888");

    static int index;

    public static String getServer() {
        if (index == list.size()) {
            index = 0;
        }

        return list.get(index++);
    }

    public static void main(String[] args) {
        for (int i = 0; i < 15; i++) {
            System.out.println(getServer());
        }
    }
}